package com.testplatform.aitestplatform.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;


import com.testplatform.common.annotation.Log;
import com.testplatform.common.core.controller.BaseController;
import com.testplatform.common.core.domain.AjaxResult;
import com.testplatform.common.core.domain.R;
import com.testplatform.common.core.page.TableDataInfo;
import com.testplatform.common.enums.BusinessType;
import com.testplatform.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.testplatform.aitestplatform.domain.TestCaseSteps;
import com.testplatform.aitestplatform.service.ITestCaseStepsService;


/**
 * 测试用例步骤明细Controller
 * 
 * @author ruoyi
 * @date 2025-10-24
 */
@Api("测试用例步骤明细管理")
@RestController
@RequestMapping("/aitestplatform/steps")
public class TestCaseStepsController extends BaseController
{
    @Autowired
    private ITestCaseStepsService testCaseStepsService;

    /**
     * 查询测试用例步骤明细列表
     */
    @ApiOperation("查询测试用例步骤明细列表")
    @PreAuthorize("@ss.hasPermi('aitestplatform:steps:list')")
    @GetMapping("/list")
    public TableDataInfo list(@ApiParam("查询条件对象") TestCaseSteps testCaseSteps)
    {
        startPage();
        List<TestCaseSteps> list = testCaseStepsService.selectTestCaseStepsList(testCaseSteps);
        return getDataTable(list);
    }

    /**
     * 导出测试用例步骤明细列表
     */
    @ApiOperation("导出测试用例步骤明细列表")
    @PreAuthorize("@ss.hasPermi('aitestplatform:steps:export')")
    @Log(title = "测试用例步骤明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(@ApiParam("导出的查询条件") HttpServletResponse response, TestCaseSteps testCaseSteps)
    {
        List<TestCaseSteps> list = testCaseStepsService.selectTestCaseStepsList(testCaseSteps);
        ExcelUtil<TestCaseSteps> util = new ExcelUtil<TestCaseSteps>(TestCaseSteps.class);
        util.exportExcel(response, list, "测试用例步骤明细数据");
    }

    /**
     * 获取测试用例步骤明细详细信息
     */
    @ApiOperation("获取测试用例步骤明细详细信息")
    @PreAuthorize("@ss.hasPermi('aitestplatform:steps:query')")
    @GetMapping(value = "/{id}")
    public R<TestCaseSteps> getInfo(@PathVariable("id") @ApiParam("测试用例步骤明细ID") Long id)
    {
        return R.ok(testCaseStepsService.selectTestCaseStepsById(id));
    }

    /**
     * 新增测试用例步骤明细
     */
    @ApiOperation("新增测试用例步骤明细")
    @PreAuthorize("@ss.hasPermi('aitestplatform:steps:add')")
    @Log(title = "测试用例步骤明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @ApiParam("新增的测试用例步骤明细对象") TestCaseSteps testCaseSteps)
    {
        return toAjax(testCaseStepsService.insertTestCaseSteps(testCaseSteps));
    }

    /**
     * 修改测试用例步骤明细
     */
    @ApiOperation("修改测试用例步骤明细")
    @PreAuthorize("@ss.hasPermi('aitestplatform:steps:edit')")
    @Log(title = "测试用例步骤明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody @ApiParam("修改的测试用例步骤明细对象") TestCaseSteps testCaseSteps)
    {
        return toAjax(testCaseStepsService.updateTestCaseSteps(testCaseSteps));
    }

    /**
     * 删除测试用例步骤明细
     */
    @ApiOperation("删除测试用例步骤明细")
    @PreAuthorize("@ss.hasPermi('aitestplatform:steps:remove')")
    @Log(title = "测试用例步骤明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable @ApiParam("要删除的测试用例步骤明细ID") Long[] ids)
    {
        return toAjax(testCaseStepsService.deleteTestCaseStepsByIds(ids));
    }
}
